#pragma once 

class CCriticalSection: public CRITICAL_SECTION
{
public:
	CCriticalSection()
	{
		InitializeCriticalSection( this );
	}

	~CCriticalSection()
	{
		DeleteCriticalSection( this );
	}

	void Lock()
	{
		EnterCriticalSection( this );
	}

	void Unlock()
	{
		LeaveCriticalSection( this );
	}
};

class CScopeLock
{
public:
	CScopeLock(CCriticalSection& iCS): m_cs(&iCS)
	{
		m_cs->Lock();
	}
	~CScopeLock()
	{
		m_cs->Unlock();
	}
private:
	CCriticalSection* m_cs;
};